package com.rpp.study.feign;

import com.rpp.study.base.LagouResponse;
import com.rpp.study.hystrix.HystrixCodeFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * @Description
 * @Author rpp
 * @Date 2020/8/28 10:35 下午
 */
@FeignClient(value = "service-code", path = "/api/code", fallbackFactory = HystrixCodeFactory.class)
public interface FeignCode {

    /**
     * ⽣成验证码并发送到对应邮箱，成功true，失败 false
     *
     * @param email
     * @return
     */
    @GetMapping(value = "/create/{email}")
    LagouResponse<Boolean> create(@PathVariable("email") String email);

    /**
     * 校验验证码是否正确，0正确1错误2超时
     *
     * @param email
     * @param code
     * @return
     */
    @GetMapping(value = "/validate/{email}/{code}")
    LagouResponse<Integer> validate(@PathVariable("email") String email,
                                    @PathVariable("code") String code);
}
